/**
 * 连接数据库
 */
import mongoose from "mongoose";
export const dbUrl = 'mongodb://localhost:27017/chembox'
// export const dbUrl = "mongodb://keiwnh2o3iuroot:isen4I3293eproot@118.31.21.163:27017/admin";
mongoose.connect(dbUrl);
mongoose.connection.once("open", () => {});

// mongoose.connection.once("close", () => {});

//使用connection监听数据库的状态
// mongoose.connection.once("open", () => {
//   console.log("connect");
// });
// mongoose.connection.once("close", () => {
//   console.log("close");
// });

// const { Schema } = mongoose;

// const langSc = {
//   label: { type: String, required: true },
//   value: { type: String, required: true },
// };

// const modelSchema = new Schema(langSc, { collection: "langen" });

// const model = mongoose.model("bb", modelSchema);
// model.create(
//   {
//     label: "setting",
//     value: "Setting",
//   },
//   function (error, result) {
//     console.log(error, result);
//     mongoose.connection.close();
//   }
// );
